package vip.george.p1572;

import vip.george.p1672.P1672;

public class P1572 {

    public int diagonalSum(int[][] mat) {
        int sum = 0;
        for (int i = 0; i < mat.length; i++) {
            int x = mat.length - 1 - i;
            int y =  i;
            if (i == x) {
                sum += mat[i][x];
            } else {
                sum += mat[i][x] + mat[i][y];
            }
        }
        return sum;
    }

    public static void main(String[] args) {
        int[][] mat = {{1,2,3},{4,5,6},{7,8,9}};
        System.out.println(new P1572().diagonalSum(mat));
        mat = new int[][]{{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}};
        System.out.println(new P1572().diagonalSum(mat));
    }
}
